﻿#pragma once
#include "yzrutil.h"
#include "DSP.h"
#include "type/Complex.h"
#include "FFT.h"


namespace yzrilyzr_dsp{
	EBCLASS(DSPUtil){
	public:
	static u_sample computeGainByRT60(u_sample delayTime, u_sample sampleRate, u_sample rt60){
		return pow(10.0, (-3 * delayTime * sampleRate) / rt60);
	}
	static u_sample computeGainByRT60(u_sample delayIndex, u_sample rt60){
		return pow(10.0, -3 * delayIndex / rt60);
	}
	static u_sample * generateChirpSamples(u_freq start, u_freq end, u_sample_rate sr, u_index length){
		u_sample * sam=new u_sample[length];
		u_sample duration=(u_sample)length / sr;
		u_sample k=(end - start) / duration;
		for(u_index i=0;i < length;i++){
			u_sample t=(u_sample)i / sr;
			sam[i]=sin(yzrilyzr_lang::Math::TAU * (start * t + 0.5 * k * t * t));
		}
		return sam;
	}	
	};

}